package routers

import (
	"api_admin_server/internal/controllers"
	"github.com/gin-gonic/gin"
	"jihe.common/protos/order_server"
	"jihe.common/protos/order_server/proto"
	"jihe.common/resp"
)

func RegisteOrder(engine *gin.Engine) {
	order := new(controllers.OrderController)
	authApi := engine.Group("auth/order")
	engine.GET("production_material/make", order.MakeProductionMaterial)

	engine.GET("composing", func(c *gin.Context) {
		ret, err := order_server.ComposingByOrderId(c, &proto.ComposingByOrderIdReq{OrderId: c.Query("order_id")})
		if err != nil {
			resp.RespGeneralErr(c, err.Error())
			return
		}
		resp.RespOk(c, ret)
	})

	authApi.POST("/list", order.GetOrderList)
	authApi.GET("/detail", order.GetOrderDetail)
	authApi.GET("/status/list", order.GetOrderStatusList)
	authApi.POST("/production_status/move", order.MoveProductionStatus)
	authApi.POST("/logistics_status/move", order.MoveLogisticsStatus)
	authApi.POST("/withdraw/list", order.GetWithDrawList)
	authApi.POST("/withdraw/status/move", order.MoveWithDrawStatus)
	authApi.GET("/production_material/list", order.GetProductionMaterialList)
}
